home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / MCQUAY1 / NEWMENU.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-30  |  2KB  |  41 lines

  1. unit NewMenu;
  2. {***********************************************************************
  3.  TMenuBoxShadow  SHADOW CLASS
  4.  This shadow class patches an undesirbale behavior in the TMenuBar Class
  5.  by patching the GetPalette method of TMenuBox Class.  TMenuBar objects
  6.  insert a TMneuBox object into the Owner of the TMenuBar object to display
  7.  submenus.  This works fine when the TMenuBar object's owner is the
  8.  desktop.  TMenuBox's palette is mapped to the desktop palette.  However,
  9.  when a TMenuBar object is inserted into something other than the desktop,
  10.  the palettes do not match.  A descendant of TMenuBar can be created that
  11.  uses a palette that matches where it is inserted, but TMenuBar will still
  12.  insert a TMenuBox object with a palette matched to TDesktop not to the
  13.  actual owner where the MenuBaar is inserted.  TNewMenuBox is a shadow
  14.  class for TMenuBox.  It modifies the behavior of the TMenuBox class'
  15.  GetPalette Method.  The new shadow GetPaalette returns the Palette of
  16.  the ParentMenu if there is one, and if not then it returns the normal
  17.  Palette of TMenuBox.
  18.  
  19.  ***********************************************************************}
  20. {$X+}
  21. interface
  22.     {Nothing Needed Here}
  23. implementation
  24.     uses Menus,views,objects,Shadow;
  25.     type
  26.         TMenuBoxShadow = object(TMenuBox)
  27.             function GetPalette:PPalette; virtual;
  28.             end;
  29.     function TMenuBoxShadow.GetPalette:PPalette;
  30.         begin
  31.         if ParentMenu=Nil then
  32.             GetPalette := TMenuView.GetPalette
  33.         else
  34.             GetPalette := ParentMenu^.GetPalette;
  35.         end;
  36.  
  37.     begin
  38. { Install the New GetPallette }
  39.     ReplaceMethod(typeof(TMenuBox),@TMenuBox.GetPalette,
  40.                                                                  @TMenuBoxShadow.GetPalette);
  41.     end.